window.onload = function () {
    var text = document.getElementById("text");
    text.onfocus = function () {
        var ser = document.getElementsByClassName("ser")[0];
        text.style.borderColor = "red";
        ser.style.borderColor = "red";
        text.onblur = function () {
            ser.style.borderColor = "#000";
        }
    }
//倒计时
var spa = document.getElementsByClassName("spa");
            //             未来时间
              var newtime = new Date("2019/1/20 00:00:00");
                      //  定义一个cl为null
                var cl = null;
                cl =setInterval(cuntdown,1000);
                      // 封装一个函数
                function cuntdown (){
                     // 现在时间
                 var nowtime = new Date();
                    // 所剩的时间
                 var lastime = parseInt((newtime-nowtime)/1000);
                 if( lastime >= 0){
                 var oday =parseInt(lastime/60/60/24);  
                 var ohuor =parseInt(lastime/60/60%24);  
                 var omin =parseInt(lastime/60%60);  
                 var osec =parseInt(lastime%60);
                 spa[0].innerHTML = ohuor;
                 spa[1].innerHTML = omin;
                 spa[2].innerHTML = osec;  
                 }else{
                     clearInterval(cl)
           }
       }
}
//二级滑动菜单
$(function () {
    $(".one").hover(function(){
        $(".lst").stop().slideDown();
    },function(){
        $(".lst").stop().slideUp();
    })
    $(".tow").hover(function(){
        $(".lst1").stop().slideDown();
    },function(){
        $(".lst1").stop().slideUp();
    })
    $(".three").hover(function(){
        $(".lst2").stop().slideDown();
    },function(){
        $(".lst2").stop().slideUp();
    })
    $(".four").hover(function(){
        $(".lst3").stop().slideDown();
    },function(){
        $(".lst3").stop().slideUp();
    })
    $(".five").hover(function(){
        $(".lst4").stop().slideDown();
    },function(){
        $(".lst4").stop().slideUp();
    })
    $(".six").hover(function(){
        $(".lst5").stop().slideDown();
    },function(){
        $(".lst5").stop().slideUp();
    })
    $(".seven").hover(function(){
        $(".lst6").stop().slideDown();
    },function(){
        $(".lst6").stop().slideUp();
    })
    $(".egit").hover(function(){
        $(".lst7").stop().slideDown();
    },function(){
        $(".lst7").stop().slideUp();
     })
    }) 
    
    //获取数据
    $(function(){
            $.get("http://47.104.244.134:8080/goodstypelist.do", {"l":2}, function (data) {
                // console.log(data)
                for(var i in data){
                 $(".conleft li").eq(i).text(data[i].name)
                }
                $(".conleft li").on("mouseleave",function(){
                    $(".fr").css({"width":"0px"});
                })
                //1
                $(".fr").on("mouseover",function(){
                    $(".fr").css({"width":"908px"});
                })
                $(".conleft li").eq(0).on("mouseover",function(){
                    $(".fr").css({"width":"908px"});
                    $.get("http://47.104.244.134:8080/goodsbytid.do", {"tid":13,"page":1,"limit":9},function(data){
                        var data = data.data;
                        var str = "";
                       for(var i = 0; i < data.length; i++){
                           str += "<li><h2>"+data[i].info+"</h2><p>"+data[i].name+"</p><img src='"+data[i].picurl+"'/><p>"+data[i].price+"</p><em>"+data[i].pubdate+"</em></li>"
                    }
                      $(".fr ul").html(str)
                    })
                });
                //2
                $(".conleft li").eq(1).on("mouseover",function(){
                      $(".fr").css({"width":"908px"});
                    $.get("http://47.104.244.134:8080/goodsbytid.do", {"tid":13,"page":2,"limit":9},function(data){
                        var data = data.data;
                        var str = "";
                       for(var i = 0; i < data.length; i++){
                           str += "<li><h2>"+data[i].info+"</h2><p>"+data[i].name+"</p><img src='"+data[i].picurl+"'/><p>"+data[i].price+"</p><em>"+data[i].pubdate+"</em></li>"
                    }
                      $(".fr ul").html(str)
                    })
                });
                //
                $(".conleft li").eq(2).on("mouseover",function(){
                      $(".fr").css({"width":"908px"});
                    $.get("http://47.104.244.134:8080/goodsbytid.do", {"tid":13,"page":3,"limit":9},function(data){
                        var data = data.data;
                        var str = "";
                       for(var i = 0; i < data.length; i++){
                           str += "<li><h2>"+data[i].info+"</h2><p>"+data[i].name+"</p><img src='"+data[i].picurl+"'/><p>"+data[i].price+"</p><em>"+data[i].pubdate+"</em></li>"
                    }
                      $(".fr ul").html(str)
                    })
                });
                //4
                 $(".conleft li").eq(3).on("mouseover",function(){
                       $(".fr").css({"width":"908px"});
                     $.get("http://47.104.244.134:8080/goodsbytid.do", {"tid":13,"page":4,"limit":9},function(data){
                         var data = data.data;
                         var str = "";
                        for(var i = 0; i < data.length; i++){
                            str += "<li><h2>"+data[i].info+"</h2><p>"+data[i].name+"</p><img src='"+data[i].picurl+"'/><p>"+data[i].price+"</p><em>"+data[i].pubdate+"</em></li>"
                     }
                       $(".fr ul").html(str)
                     })
                 });
                 //5
                 $(".conleft li").eq(4).on("mouseover",function(){
                       $(".fr").css({"width":"908px"});
                     $.get("http://47.104.244.134:8080/goodsbytid.do", {"tid":13,"page":5,"limit":9},function(data){
                         var data = data.data;
                         var str = "";
                        for(var i = 0; i < data.length; i++){
                            str += "<li><h2>"+data[i].info+"</h2><p>"+data[i].name+"</p><img src='"+data[i].picurl+"'/><p>"+data[i].price+"</p><em>"+data[i].pubdate+"</em></li>"
                     }
                       $(".fr ul").html(str)
                     })
                 });
                 //index获取数据
                 $.get("http://47.104.244.134:8080/goodsbytid.do", {"tid":13,"page":2,"limit":4},function(data){
                    var data = data.data;
                    var str = "";
                   for(var i = 0; i < data.length; i++){
                       str += "<li><img src='"+data[i].picurl+"'/><p>"+data[i].price+"</p><em>"+data[i].pubdate+"</em></li>"
                }
                  $(".list ul").html(str)
                });
                //index bg获取数据
                 $.get("http://47.104.244.134:8080/goodsbytid.do", {"tid":13,"page":2,"limit":8},function(data){
                    var data = data.data;
                    var str = "";
                   for(var i = 0; i < data.length; i++){
                       str += "<li><img src='"+data[i].picurl+"'/><p>"+data[i].price+"</p><em>"+data[i].pubdate+"</em></li>"
                }
                  $(".bg ul").html(str);
                });
                // index hg获取数据
                $.get("http://47.104.244.134:8080/goodsbytid.do", {"tid":13,"page":1,"limit":8},function(data){
                    var data = data.data;
                    var str = "";
                   for(var i = 0; i < data.length; i++){
                       str += "<li><img src='"+data[i].picurl+"'/><p>"+data[i].price+"</p></li>"
                }
                  $(".hg ul").html(str)
                });
                //向前翻页
                $("#qian").on("click",function(){
                    $.get("http://47.104.244.134:8080/goodsbytid.do", {"tid":13,"page":1,"limit":4},function(data){
                        var data = data.data;
                        var str = "";
                       for(var i = 0; i < data.length; i++){
                           str += "<li><img src='"+data[i].picurl+"'/><p>"+data[i].price+"</p><em>"+data[i].pubdate+"</em></li>"
                    }
                      $(".list ul").html(str)
                    });
                })
                //向后翻页
                $("#hou").on("click",function(){
                    $.get("http://47.104.244.134:8080/goodsbytid.do", {"tid":13,"page":3,"limit":4},function(data){
                        var data = data.data;
                        var str = "";
                       for(var i = 0; i < data.length; i++){
                           str += "<li><img src='"+data[i].picurl+"'/><p>"+data[i].price+"</p><em>"+data[i].pubdate+"</em></li>"
                    }
                      $(".list ul").html(str)
                    });
                    
                }) 
            })
        })
//轮播图
$(function(){
    var obj={};
    var i=0;
    neirong (0);
    function neirong (i) {
        $("#img li").eq(i).siblings().css("opacity","0");
        $("#img li").eq(i).css("opacity","1")       
        $("#nav1 ul li").eq(i).siblings().removeClass("select");
        $("#nav1 ul li").eq(i).addClass("select");
    }		    	
    lunbo();
    function lunbo(){
        clearInterval(obj.timer);
        obj.timer=setInterval(function(){
        i++;
        if(i>4){
            i=0;
        }
        if(i<0){
            i=0;
        }
        neirong(i)		    					    		   		
        },3000)
    }
    $("#nav1 ul li").on("click",function(){
        i=$(this).index();
        neirong(i);	    		
    })
    $(".conright").on("mouseenter",function(){
        clearInterval(obj.timer);
    })
    $(".conright").on("mouseout",function(){
        lunbo();
    })
    $(".lift").on("click",function(){
        i=i-1;
        if(i<0){
            i=4
        }
        neirong(i);
    })
    $(".lirh").on("click",function(){
        i=i+1;
        if(i>4){
            i=0;
        }
        neirong(i);
    })
})
